package com.handydata.antifraud.rule;

import com.bstek.urule.model.flow.ins.FlowContext;

import java.util.Map;
import java.util.Optional;

public class RuleEngineVarCollector {
    @SuppressWarnings("unchecked")
	public static <T> Optional<T> collect(FlowContext context, Class<T> cls) {
        Map<String, Object> factsMap = context.getWorkingMemory().getAllFactsMap();
        Object obj = factsMap.get(cls.getName());

        return Optional.ofNullable((T)obj);
    }
    public static Map<String, Object> collectAll(FlowContext context) {
        return context.getWorkingMemory().getAllFactsMap();
    }
}
